﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Windows.Forms;
using University.Workshop.Model;
using University.Workshop.Business;
using System.Data.SqlClient;



namespace University.Workshop.Presenters
{
  public  class PresenterLogOn
    {
        ILogOn view;
        public PresenterLogOn(ILogOn view)
        {
            this.view = view;
        }
        public string Logged()
        {
            LogOn log = new LogOn(view.UserName, view.Password);
            try
            {
                if (LogOnManager.LogOnFunction(log))
                {
                    return "Bienvenido "+view.UserName;
                }
                else
                {
                    return "El usuario no se encuentra registrado";
                }
            }
            catch (SqlException ex)
            {
                return "error"+ex;
                //MessageBox.Show(ex.Message);
            }
        }

        public User ObtainLoggedUser()
        {
            return UserManager.GetUserByUserName(view.UserName);
        }
    }
}

